package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

public enum ProductType implements IBaseEnum<Serializable> {
    /**
     * 产品类型1：
     */
    WAIT_SEND(1,"桶装"),
    /**
     * 产品类型2：
     */
    SENT(2,"袋装"),
    /**
     * 产品类型3：
     */
    TASK_FINISH(3,"箱装"),
    ;

    @EnumValue
    private int code;
    @JsonValue
    private String des;

    ProductType(int code, String des) {
        this.code = code;
        this.des = des;
    }

    @Override
    public String toString() {
        return des;
    }

    @Override
    public Integer getValue() {
        return code;
    }

    public static ProductType parseProductType(int productType) {
        ProductType[] productTypes = ProductType.values();
        for (ProductType type : productTypes) {
            if (type.code == productType) {
                return type;
            }
        }
        throw new IllegalArgumentException("产品类型参数异常");
    }

    @Override
    public String getDescription() {
        return des;
    }

    @Override
    public Integer getVal(){
        return code;
    }
}
